let invoices = [{
    name: 'santa Monica',
    number: 1995,
    amount: '$10,800',
    due: '12/05/1995'
  },
  {
    name: 'sonyman',
    number: 2000,
    amount: '$8,800',
    due: '12/31/1991'
  },
  {
    name: 'lucy young',
    number: 1992,
    amount: '$11,800',
    due: '2/05/1992'
  },
  {
    name: 'Ocean Avene',
    number: 2001,
    amount: '$6,800',
    due: '11/11/2002'
  },
  {
    name: 'tycan wong',
    number: 1993,
    amount: '$7,800',
    due: '22/05/1996'
  },
  {
    name: 'Lady Gaga',
    number: 1990,
    amount: '$9,800',
    due: '11/03/2003'
  }
]

//获取整个列表
function getInvoices() {
  return invoices;
}

//获取列表中某一项
function getInvoice(number) {
  let item = invoices.filter(invoice => invoice.number === number)[0];
  // console.log(item);
  //{name: 'lucy young', number: 1992, amount: '$11,800', due: '2/05/1992'}

  return item;
}

//删除数据
function deleteInvoice(number) {
  invoices = invoices.filter(invoice => invoice.number !== number);
}

export {
  getInvoices,
  getInvoice,
  deleteInvoice
}